#include "scorekeeper.h"

scorekeeper *scorekeeper::instance = NULL;

scorekeeper* scorekeeper::getInstance(){
	if(!instance){
		instance = new scorekeeper();
	}
	return instance;
}

scorekeeper::scorekeeper(){
	s_score=0;
	s_shotsFired=0;
	s_shotsLanded=0;
	s_shotsHit=0;
	s_totalItems=0;
	s_grabbedItems=0;
	s_jumps=0;
	s_playerHit=0;
	s_deaths=0;
	s_enemies=0;
	s_enemyDeaths=0;
	totalScore=0;
	totalShots=0;
	totalShotsHit=0;
	totalDamageDid=0;
	totalItems=0;
	totalGrabbed=0;
	totalJumps=0;
	totalDamageTaken=0;
	totalDeaths=0;
	totalEnemies=0;
	totalKills=0;
}

scorekeeper::~scorekeeper(){
}

void scorekeeper::increaseScore(int score){
	s_score += score;
}


void scorekeeper::increaseShots(){
	s_shotsFired++;
}

void scorekeeper::increaseShotsLanded(){
	s_shotsLanded++;
}

void scorekeeper::increaseHits(int damage){
	s_shotsHit += damage;
}

void scorekeeper::increaseItems(){
	s_grabbedItems++;
}

void scorekeeper::increaseItemCount(){
	s_totalItems++;
}

void scorekeeper::increaseJumps(){
	s_jumps++;
}

void scorekeeper::increaseHurt(int damage){
	s_playerHit += damage;
}
void scorekeeper::increaseDeaths(){
	s_deaths++;
}

void scorekeeper::increaseEnemyCount(){
	s_enemies++;
}

void scorekeeper::increaseKills(){
	s_enemyDeaths++;
}

void scorekeeper::resetLevelScore(){
	s_score=0;
	s_shotsFired=0;
	s_shotsLanded=0;
	s_shotsHit=0;
	s_totalItems=0;
	s_grabbedItems=0;
	s_jumps=0;
	s_playerHit=0;
	s_deaths=0;
	s_enemies=0;
	s_enemyDeaths=0;
}

void scorekeeper::levelReport(){
	//Don't count the next level powerup.
	s_grabbedItems--;
	consoleClear();
	printf("\n\n\n\n\n\n\n");
	//         |start here            |end here?
	printf("    Score and Stats:  \n");
	printf("    Score: %i\n",s_score);
	printf("    Shots Fired: %i\n",s_shotsFired);
	printf("    Shots Hit:%i\n",s_shotsLanded);
	printf("    Enemies Killed:%i\n",s_enemyDeaths);
	printf("    Jumps:%i\n",s_jumps);
	printf("    Items Picked Up:%i\n",s_grabbedItems);
	printf("    Damage Done:%i\n",s_shotsHit);
	printf("    Damage Taken:%i\n",s_playerHit);
	printf("    Deaths:%i\n",s_deaths);
	printf("    Press A Button to continue\n");
	
	totalScore += s_score;
	totalShots += s_shotsFired;
	totalShotsHit += s_shotsLanded;
	totalDamageDid += s_shotsHit;
	totalItems += s_totalItems;
	totalGrabbed += s_grabbedItems;
	totalJumps += s_jumps;
	totalDamageTaken += s_playerHit;
	totalDeaths += s_deaths;
	totalEnemies += s_enemies;
	totalKills += s_enemyDeaths;
	
	resetLevelScore();

	bool stats=true;
	while(stats){
		scanKeys();
		if(keysDown() & KEY_A){
			stats=false;
		}
	}
}

void scorekeeper::gameReport(){
	consoleClear();
	printf("\n\n\n\n\n\n\n");
	//         |start here            |end here?
	printf("    Score and Stats:  \n");
	printf("    Score: %i\n",totalScore);
	printf("    Shots Fired: %i\n",totalShots);
	printf("    Shots Hit:%i\n",totalShotsHit);
	printf("    Enemies Killed:%i\n",totalKills);
	printf("    Jumps:%i\n",totalJumps);
	printf("    Items Picked Up:%i\n",totalGrabbed);
	printf("    Damage Done:%i\n",totalDamageDid);
	printf("    Damage Taken:%i\n",totalDamageTaken);
	printf("    Deaths:%i\n",totalDeaths);
//	printf("    Press A Button to continue\n");

	bool stats=true;
	while(stats){
		scanKeys();
		if(keysDown() & KEY_A){
//			stats=false;
		}
	}
}

int scorekeeper::getScore(){
	return totalScore+s_score;
}